package java_thinking.unit_9._9_1;

/**
 * @Description :
 * @author: cww
 * @DateTime: 2019-03-02 15:47
 */

/**
 * 不带抽象方法的抽象类
 */
abstract class Practice_4 {
}

class Extend1 extends Practice_4{
    public void f(){
        System.out.println("Extend1.f()");
    }
}

/**
 * 带抽象方法的抽象类
 */
abstract class WithMethods{
    abstract void f();
}
class Extend2 extends WithMethods{
    @Override
    public void f(){
        System.out.println("Extend2.f()");
    }
}
class AbstractBase{
    public static void test1(Practice_4 practice4){
        //必须向下转型才能调用f()
        ((Extend1)practice4).f();
    }

    public static void test2(WithMethods withMethods){
        //父类有该方法了，就不需要转型了
        withMethods.f();
    }
    public static void main(String[] args) {
        Practice_4 practice_4 = new Extend1();
        test1(practice_4);
        WithMethods withMethods = new Extend2();
        withMethods.f();
    }
}